<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="p_type" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="popAddCertificateType('')" type='success' size="mini"><i class='fa fa-plus'></i>增加类型</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 证书类型 </span>
      </div>
      <el-table :data="p_type">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_type('&CMIDtype_id='+scope.row.type_id+'')">删除</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="popAddCertificateTypes('&CMIDtype_id='+scope.row.type_id+'')">修改</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="认证类型" prop="setup_name">
        </el-table-column>
        <el-table-column label="证书类型" prop="type_name">
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
    <el-dialog :visible.sync="AddCertificateTypeVisible" append-to-body>
      <AddCertificateType v-if="AddCertificateTypeVisible" ref="AddCertificateType" :popparams="popparams"> </AddCertificateType>
    </el-dialog>
    <el-dialog :visible.sync="AddCertificateTypesVisible" append-to-body>
      <AddCertificateTypes v-if="AddCertificateTypesVisible" ref="AddCertificateTypes" :popparams="popparams"> </AddCertificateTypes>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import AddCertificateType from "@/views/mes/certificate/AddCertificateType";
  import AddCertificateTypes from "@/views/mes/certificate/AddCertificateTypes";
  export default {
    name: 'CertificateType',
    components: {
      AddCertificateType,
      AddCertificateTypes,
    },
    props: ['popparams'],
    data() {
      return {
        AddCertificateTypeVisible: false,
        AddCertificateTypeValue: null,
        AddCertificateTypeDesc: null,
        AddCertificateTypesVisible: false,
        AddCertificateTypesValue: null,
        AddCertificateTypesDesc: null,
        vueparams: this.getVUEParams(""),
        p_type: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/certificateType?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_type(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/d_type?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popAddCertificateType(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AddCertificateTypeVisible = !this.AddCertificateTypeVisible;
      },
      popAddCertificateTypes(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AddCertificateTypesVisible = !this.AddCertificateTypesVisible;
      },
    },
  }
</script>
